package com.example.aidl_test.common;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

public class Book implements Parcelable {

    private int mID;
    private String mName;

    protected Book(Parcel in) {
        mID = in.readInt();
        mName = in.readString();
    }

    public Book(int mID, String mName) {
        this.mID = mID;
        this.mName = mName;
    }

    public int getID() {
        return mID;
    }

    public String getName() {
        return mName;
    }

    @Override
    public String toString() {
        return "Book{" +
                "mID=" + mID +
                ", mName='" + mName + '\'' +
                '}';
    }

    public static final Creator<Book> CREATOR = new Creator<Book>() {
        @Override
        public Book createFromParcel(Parcel in) {
            return new Book(in);
        }

        @Override
        public Book[] newArray(int size) {
            return new Book[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mID);
        dest.writeString(mName);
    }
}
